﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Services;

namespace DearInformation.Controllers
{
    public class UserController : Controller
    {
        //
        // GET: /User/

        public ActionResult UserList()
        {
            ViewData["uid"] = ((User)Session["user"]).Uid;
            return View();
        }

        public JsonResult GetOurInfo()
        {
            UserServer server = new UserServer();
            List<User> list = server.GetAllUser();
            return Json(Json(list), JsonRequestBehavior.AllowGet);
        }

        public ActionResult UserInfo(string tag,string uid)
        {
            ViewData["uid"] = uid;
            ViewData["tag"] = tag;
            UserServer server = new UserServer();
            Services.User user = server.GetUserById(uid);
            return View(user);
        }

        public ActionResult EditUser(User user)
        {
            UserServer server = new UserServer();
            server.Update(user);
            return RedirectToAction("UserList", "User");
        }
    }
}
